//
//  BAKit_WholeView.m
//  BASorterSelectedView
//  全部
//  Created by Mr_zhang on 2017/9/13.
//  Copyright © 2017年 Mr_zhang. All rights reserved.
//

#import "BAKit_WholeView.h"

#define CellHeight 35
@interface BAKit_WholeView()

@property(nonatomic, strong) UITableView *wholeTableView;

//@property(nonatomic, strong) NSMutableDictionary *dataDict;

@property(nonatomic, strong) NSArray *dataArray;

@end

@implementation BAKit_WholeView

- (NSArray *)dataArray
{
    if (!_dataArray)
    {
        _dataArray = @[@"全部",@"生日蛋糕",@"火锅",@"自助餐",@"小吃快餐",@"日本料理",@"生鲜蔬菜",@"聚餐宴请",@"烧烤烤肉",@"川湘菜"];
    }
    return _dataArray;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self setUpSubView];
    }
    return self;
}

- (void)setUpSubView
{
    self.wholeTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) style:UITableViewStylePlain];
    self.wholeTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.wholeTableView.delegate = self;
    self.wholeTableView.dataSource = self;
    [self addSubview:_wholeTableView];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.textLabel.text = [NSString stringWithFormat:@"%@",self.dataArray[indexPath.row]];
    cell.textLabel.textColor = [UIColor blackColor];
    cell.textLabel.font = [UIFont systemFontOfSize:13];
    
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, CellHeight - 1, self.frame.size.width, 1)];
    lineView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [cell.contentView addSubview:lineView];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   // NSArray *areaKeys = [self.dataDict allKeys];
//    NSString *areObject = self.dataArray[indexPath.row];
//    for (NSString *areaKey in areaKeys) {
//        if ([[self.dataDict objectForKey:areaKey] isEqualToString:areObject])
//        {
//            self.workplaceBlcok(areObject,areaKey);
//        }
//    }
   // self.workplaceBlcok(areObject, nil);
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return CellHeight;
}

@end
